﻿; (function (window, undefined, $) {
    var submiting = false;
    $('#frmEdit').validator({
        rules: {

        },
        fields: {
            '#AssetName': 'required',
            '#Assetmanagers': 'required',
            '#Assetcustodians': 'required',
            '#Minamount': 'required',
            '#Deadline': 'required',
            '#AccountName': 'required',
            '#AccountNumber': 'required'
            //'#Bank': 'required'
        },
        valid: function (form) {
            if (submiting) {
                return;
            }
            submiting = true;
            FormSubmit(form, function(res) {
                if (res.Status > 0) {
                    //layer.msg(res.Message, 2, 1);
                    alert(res.Message);
                    window.location.href = "/Admin/Asset/Assetlist";
                } else if (res.Status == -2) {
                    alert(res.Message);
                    $("#AccountName").focus();
                } else if (res.Status == -3) {
                    alert(res.Message);
                    $("#AccountNumber").focus();
                } else {
                    alert(res.Message);
                }
                submiting = false;
            });
        }
    });


    $("#btnSave").click(function (e) {
        $("#hideRemark").val($("#Remark").val());
        $("#frmEdit").submit();
    });
    $("#btnReturn").click(function (e) {
        window.location.href = "/Admin/Asset/Assetlist";
    });
    util.getFloatStr = function (id, num) {
        num = num.replace(/[^0-9|\.]/g, ''); //清除字符串中的非数字非.字符
        var no = changeTwoDecimal(parseFloat(num));
        if (!no) {
            $('#' + id).val('');
        }
        else {
            $('#' + id).val(no.toFixed(2));
        }
    };

    function changeTwoDecimal(x) {

        if (isNaN(x)) {
            return false;
        }
        f_x = Math.round(x * 100) / 100;
        return f_x;
    }
})(window, undefined, jQuery);